﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
namespace plvs
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            try
            {
                InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new CultureInfo("en-US"));
            }
            catch
            {
                MessageBox.Show("You have not installed en-US language on your system . . .","Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            }
        }

        private void sendtab(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                SendKeys.Send("{Tab}");
            }
        }

        private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            pictureBox3_Click(sender, new EventArgs());
        }
        int _login;
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            if(txt_UserName.Text==string.Empty)
            {
            txt_UserName.BackColor=Color.Red;
            }
            else{
            txt_UserName.BackColor=Color.FromArgb(25, 35, 45);
            }
         if(new LoginClass().CheckLogin(txt_UserName.Text.Trim(),txt_Password.Text.Trim()))
         {
         this.Close();
             new Main.frmMain().ShowDialog();
         }else{
         _login++;
             switch (_login)
	{
		case 1:
                     txt_UserName.Clear();
                     txt_Password.Clear();
                     txt_UserName.Focus();
                     new PublicClass1().PlaySoundAlarm();
                     System.Threading.Thread.Sleep(1000);
 break;
	}
         }
           
           
        }
        #region pictureboxes_Click_Simulation
        private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
        {
            pictureBox3.Left++;
            pictureBox3.Top++;
        }

        private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
        {
            pictureBox3.Left--;
            pictureBox3.Top--;
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            pictureBox1.Left++;
            pictureBox1.Top++;
        }

        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            pictureBox1.Left--;
            pictureBox1.Top--;
        }
        #endregion

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }


    }
}
